using System;
using System.Collections;
using System.IO;
namespace Extra.Data.Extra.Class
{
	public class FileComparer : IComparer
	{
		public enum CompareBy
		{
			Name,
			LastWriteTime,
			CreationTime,
			LastAccessTime,
			FileSize
		}
		private int _CompareBy = 0;
		public FileComparer()
		{
		}
		public FileComparer(FileComparer.CompareBy compareBy)
		{
			this._CompareBy = (int)compareBy;
		}
		int IComparer.Compare(object x, object y)
		{
			DirectoryInfo directoryInfo = new DirectoryInfo(x.ToString());
			DirectoryInfo directoryInfo2 = new DirectoryInfo(y.ToString());
			int result;
			switch (this._CompareBy)
			{
			case 1:
				result = DateTime.Compare(directoryInfo.LastWriteTime, directoryInfo2.LastWriteTime);
				return result;
			case 2:
				result = DateTime.Compare(directoryInfo.CreationTime, directoryInfo2.CreationTime);
				return result;
			case 3:
				result = DateTime.Compare(directoryInfo.LastAccessTime, directoryInfo2.LastAccessTime);
				return result;
			}
			result = new CaseInsensitiveComparer().Compare(directoryInfo.Name, directoryInfo2.Name);
			return result;
		}
	}
}
